<?php


namespace App\Services\Game;


use App\DTOS\Admin\HorseRaceLampDTO;
use App\DTOS\Admin\RoleCoordinatesDTO;
use App\Models\Game\HorseRaceLamp;
use App\Models\Game\RoleCoordinates;

class RoleCoordinatesService
{

    /**
     * @param HorseRaceLampDTO $dto
     * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
     */
    public function paginate(RoleCoordinatesDTO $dto){
        $pageSize = $dto->getLimit();
        $page = $dto->getPage();
        $type = $dto->getType();
        $RoleId= $dto->getRoleId();
        $content = $dto->getContent();
        $model = RoleCoordinates::query();

        if ($content){
            $model->where('content',"like","%$content%");
        }
        if ($RoleId){
            $model->where('RoleId',$RoleId);
        }
        if ($type ){
            $model->where('type',$type);
        }
        return $model->orderByDesc('created_at')->paginate($pageSize,'*','page',$page);
    }

}
